//使用promise的方式来封装wx原生api
export default {
  //获取用户授权的所有相关信息
  getSetting: function () {
    return new Promise((resolve, reject) => {
      wx.getSetting({
        withSubscriptions: true,
        success: (res) => {
          resolve(res)
        },
        fail: (err) => {
          reject(err)
        }
      })
    })
  },
  //打开用户授权界面
  openSetting: function () {
    return new Promise((resolve, reject) => {
      wx.openSetting({
        withSubscriptions: true,
        success: (res) => {
          resolve(res)
        },
        fail: (err) => {
          reject(err)
        }
      })
    })
  },
  //获取wx收获地址
  chooseAddress: function () {
    return new Promise((resolve, reject) => {
      wx.chooseAddress({
        success: (res) => {
          resolve(res)
        },
        fail: (err) => {
          reject(err)
        }
      })
    })
  },
  //showTost封装
  showToast:function(msg){
    return new Promise((resolve, reject) => {
      wx.showToast({
        title: msg,
        icon:'none',
        success: (res) => {
          resolve(res)
        },
        fail: (err) => {
          reject(err)
        }
      })

    })

  }

}